package com.gopay.common.domain.bis;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.gopay.common.cipher.utils.SensitiveInfoUtils;
import com.gopay.common.domain.BaseEntity;

/**
 * 银行交互服务-银行用户签约信息表
 *
 * @author wangxintao
 * @BisBankContractInfo.java
 * @2016-05-17 上午10:35:20 www.gopay.com.cn Inc.All rights reserved.
 */
@Entity
@Table(name = "BIS_BANK_CONTRACT_INFO")
public class BisBankContractInfo extends BaseEntity {

    /**
     *
     */
    private static final long serialVersionUID = 0;

    /**
     * 流水号
     */
   private int id;

    /**
     * 银行代码              spdb - 浦发银行
     */
    private String bankCode;

    /**
     * 银行业务产品代码      15 - 个人借记卡    05-贷记卡
     */
    private String bankBizProdCode;

    /**
     * 接口通道代码
     * <p>
     * 00 - 直连银行
     * 01 - 联动优势
     * 02 - 联通沃
     * 03 - 深圳快付通
     * 04 - 民生银联
     */
    private String intrfaceChannelCode;

    /**
     * 签约日期
     */
    private Date contractDate;

    /**
     * 签约有效期
     */
    private String contractExpiryDate;

    /**
     * 卡号
     */
    private String cardNo;

    /**
     * 签约状态   01：已签约（如果用户已解约或签约过期导致签约失败则修改为   02:签约作废，下次需重新发起签约）
     */
    private String contractState;

    /**
     * 签约描述 （记录签约失败的原因）
     */
    private String contractDesc;

    /**
     * 签约码/绑卡ID   （有些银行签约后/绑卡后会返回签约码/绑卡ID，支付时使用）
     */
    private String contractNumber;

    /**
     * 签约限额
     */
    private BigDecimal dayLimit;

    /**
     * 累计限额
     */
    private BigDecimal countLimit;

    /**
     * 乐观锁版本号
     */
    private Long version;

    /**
     * 创建时间
     */
    private Date createdTs;

    /**
     * 最后修改时间
     */
    private Date lastUpdTs;
    
    /**
     * 绑定手机号
     */
    private String bindMobile; 
    
    /**
     * 四要素校验码
     */
    private String verificationCode; 
    
    /**
     * 四要素校验码
     */
    private String ueserId;
    
    @Id
    @Column(name = "ID", nullable = false)
    @SequenceGenerator(name = "BIS_BANK_CONTRACT_INFO_SQ_GENERATOR", sequenceName = "BIS_BANK_CONTRACT_INFO_SEQ")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "BIS_BANK_CONTRACT_INFO_SQ_GENERATOR")
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Column(name = "BANK_CODE", nullable = false)
    public String getBankCode() {
        return bankCode;
    }

    public void setBankCode(String bankCode) {
        this.bankCode = bankCode;
    }

    @Column(name = "BANK_BIZ_PROD_CODE", nullable = false)
    public String getBankBizProdCode() {
        return bankBizProdCode;
    }

    public void setBankBizProdCode(String bankBizProdCode) {
        this.bankBizProdCode = bankBizProdCode;
    }

    @Column(name = "INTRFACE_CHANNEL_CODE", nullable = false)
    public String getIntrfaceChannelCode() {
        return intrfaceChannelCode;
    }

    public void setIntrfaceChannelCode(String intrfaceChannelCode) {
        this.intrfaceChannelCode = intrfaceChannelCode;
    }

    @Column(name = "CONTRACT_DATE", nullable = false)
    public Date getContractDate() {
        return contractDate;
    }

    public void setContractDate(Date contractDate) {
        this.contractDate = contractDate;
    }

    @Column(name = "CONTRACT_EXPIRY_DATE")
    public String getContractExpiryDate() {
        return contractExpiryDate;
    }

    public void setContractExpiryDate(String contractExpiryDate) {
        this.contractExpiryDate = contractExpiryDate;
    }

    @Column(name = "CARD_NO", nullable = false)
    public String getCardNo() {
        /**
    	 * modify by zyt，2017-2-22在程序中获取的时候进行解密操作，如果是hibernate自己调用（save等），则返回原值；
    	 */
    	this.cardNo = SensitiveInfoUtils.autoReencrypt(this.cardNo);
    	return SensitiveInfoUtils.smartDecryptWithCheck(this.cardNo);
    }

    public void setCardNo(String cardNo) {
        /**
    	 * modified by zyt，2017-2-22 判断传入字符串是否经过加密，如果是，则设置为原文，否则设置为加密后的值
    	 */
    	this.cardNo = SensitiveInfoUtils.smartEncryptWithCheck(cardNo);
    }

    @Column(name = "CONTRACT_STATE")
    public String getContractState() {
        return contractState;
    }

    public void setContractState(String contractState) {
        this.contractState = contractState;
    }

    @Column(name = "CONTRACT_DESC")
    public String getContractDesc() {
        return contractDesc;
    }

    public void setContractDesc(String contractDesc) {
        this.contractDesc = contractDesc;
    }

    @Column(name = "CONTRACT_NUMBER")
    public String getContractNumber() {
        return contractNumber;
    }

    public void setContractNumber(String contractNumber) {
        this.contractNumber = contractNumber;
    }

    @Column(name = "DAY_LIMIT")
    public BigDecimal getDayLimit() {
        return dayLimit;
    }

    public void setDayLimit(BigDecimal dayLimit) {
        this.dayLimit = dayLimit;
    }

    @Column(name = "COUNT_LIMIT")
    public BigDecimal getCountLimit() {
        return countLimit;
    }

    public void setCountLimit(BigDecimal countLimit) {
        this.countLimit = countLimit;
    }

    @Column(name = "VERSION")
    public Long getVersion() {
        return version;
    }

    public void setVersion(Long version) {
        this.version = version;
    }

    @Column(name = "CREATED_TS")
    public Date getCreatedTs() {
        return createdTs;
    }

    public void setCreatedTs(Date createdTs) {
        this.createdTs = createdTs;
    }

    @Column(name = "LAST_UPD_TS")
    public Date getLastUpdTs() {
        return lastUpdTs;
    }

    public void setLastUpdTs(Date lastUpdTs) {
        this.lastUpdTs = lastUpdTs;
    }

    @Column(name = "BIND_MOBILE")
    public String getBindMobile() {
		//return bindMobile;
        /**
         * modified by zyt 2017-4-10 自动重新加密并解密返回
         */
        this.bindMobile = SensitiveInfoUtils.autoReencrypt(this.bindMobile);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.bindMobile);
	}

	public void setBindMobile(String bindMobile) {
		//this.bindMobile = bindMobile;
        /**
         * modified by zyt 2017-4-10 写操作的时候做加密
         */
        this.bindMobile = SensitiveInfoUtils.smartEncryptWithCheck(bindMobile);
	}

	@Column(name = "VERIFICATION_CODE")
    public String getVerificationCode() {
		return verificationCode;
	}

	public void setVerificationCode(String verificationCode) {
		this.verificationCode = verificationCode;
	}

	@Column(name = "USER_ID")
    public String getUeserId() {
		//return ueserId;
        /**
         * modified by zyt 2017-4-10 自动重新加密并解密返回
         */
        this.ueserId = SensitiveInfoUtils.autoReencrypt(this.ueserId);
        return SensitiveInfoUtils.smartDecryptWithCheck(this.ueserId);
	}

	public void setUeserId(String ueserId) {
		//this.ueserId = ueserId;
        /**
         * modified by zyt 2017-4-10 写操作的时候做加密
         */
        this.ueserId = SensitiveInfoUtils.smartEncryptWithCheck(ueserId);
	}
	
}
